/*
@STI LICENSE
(C) 2006-2008 Universit�t Innsbruck.

This file is part of myOntology.

myOntologyis free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

myOntologyis distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with myOntology.  If not, see <http://www.gnu.org/licenses/>.

@STI LICENSE */
package model.dataContainer;


import java.util.ArrayList;
import java.util.Date;

import org.apache.log4j.Logger;
import org.openrdf.model.URI;

public abstract class AbstractElement {

	protected URI id;
	
	protected String label;
	protected String comment;
	protected java.util.Date hasVersionDateTime;
	protected ArrayList<URI> seeAlso;
	protected ArrayList<URI> belongsToOntologyModule;
	protected ArrayList<TranslationContainer> translations;
	protected ArrayList<String> synonyms;
	protected ArrayList<String> tags;
	protected String example;
	protected ArrayList<String> flickrImages;
	protected ArrayList<String> youTubeVideos;
	protected URI hasPreviousVersion;

	public static Logger logger = Logger.getLogger(AbstractElement.class);
	
	public AbstractElement() {
		
		label = null;
		comment = null;
		hasVersionDateTime = null;		
		seeAlso = null;
		belongsToOntologyModule = null;
		translations = null;
		synonyms = null;
		tags = null;
		example = null;
		flickrImages = null;
		youTubeVideos = null;
		
		hasPreviousVersion = null;
	}
	


	public boolean setId( URI val) {	
		boolean ret = true;
		
		this.id = val;

		return ret;
	}
	

	
	public boolean setTranslations( ArrayList<TranslationContainer> val ) {
		
		boolean ret = true;
		
		this.translations = val;
		
		return ret;
	}
	
	public boolean addTranslation(TranslationContainer val) throws Exception {
		boolean ret = true;
		try {			
			if (val!=null ) {
				this.translations.add( val );
			}
		} catch (Exception e) {
			ret = false;
			logger.error(e);
			
			throw e;
		}
		return ret;
	}
		

	
	public boolean setSynonyms(ArrayList<String> val) throws Exception {

		boolean ret = true;
		
		this.synonyms = val;
		
		return ret;
	}	
	
	public boolean addSynonym(String val) throws Exception {
		boolean ret = true;
		try {
			if (val != null && !val.trim().equals("")) {

				if( this.synonyms==null)
					this.synonyms = new ArrayList<String>();
				
				this.synonyms.add(val.trim());
			}
		} catch (Exception e) {
			ret = false;
			logger.error(e);
			
			throw e;
		}
		return ret;
	}
	

	public boolean setTags(ArrayList<String> val) throws Exception {

		boolean ret = true;
		
		this.tags = val;
		
		return ret;
	}	
	
	public boolean addTag(String val) throws Exception {
		boolean ret = true;
		try {
			if (val != null && !val.trim().equals("") ) {

				if( this.tags==null)
					this.tags = new ArrayList<String>();
				
				this.tags.add(val.trim());
			}
		} catch (Exception e) {
			ret = false;
			logger.error(e);
			
			throw e;
		}
		return ret;
	}
	

	public boolean setFlickrImages(ArrayList<String> val) throws Exception {

		boolean ret = true;
		
		this.flickrImages = val;
		
		return ret;
	}		
	
	public boolean addFlickrImage(String val) throws Exception {
		boolean ret = true;
		try {
			if (val != null && !val.trim().equals("") ) {
				
				if( this.flickrImages==null)
					this.flickrImages = new ArrayList<String>();
				
				this.flickrImages.add(val.trim());
			}
		} catch (Exception e) {
			ret = false;
			logger.error(e);
			
			throw e;
		}
		return ret;
	}


	public boolean setYouTubeVideos(ArrayList<String> val) throws Exception {

		boolean ret = true;
		
		this.youTubeVideos = val;
		
		return ret;
	}		
	
	public boolean addYouTubeVideo(String val) throws Exception {
		boolean ret = true;
		try {
			if (val != null && !val.trim().equals("")) {

				if( this.youTubeVideos==null)
					this.youTubeVideos = new ArrayList<String>();
				
				this.youTubeVideos.add(val.trim());
			}
		} catch (Exception e) {
			ret = false;
			logger.error(e);
			
			throw e;
		}
		return ret;
	}
	
	public boolean setExample(String val) {
		if( val!=null)
			this.example = val.trim();
		return true;
	}
	
	public boolean setLabel(String entry) {
		
		if( entry!=null)
			this.label = entry.trim();		
		
		return true;
	}
	
	public boolean setComment(String entry) {
		if( entry!=null)
			this.comment = entry.trim();		
		return true;
	}
	
	public boolean setHasVersionDateTime(Date entry) {
		if( entry!=null)
			this.hasVersionDateTime = entry;		
		return true;
	}
	
	
	public boolean setSeeAlso(ArrayList<URI> val){
		boolean ret = true;
		
		this.seeAlso = val;
		
		return ret;
	}
	
	public boolean addSeeAlso(URI val) throws Exception {
		boolean ret = true;
		
		try {
			if( val != null ) {

				if( this.seeAlso==null)
					this.seeAlso = new ArrayList<URI>();
				
				this.seeAlso.add( val );
			}
			
		} catch (Exception e) {
			logger.error( this.getClass().toString() + " addSeeAlso(): " + e.getMessage() );
			ret = false;
			
			throw e;
		}
		return ret;
	}
	
	
	public boolean setBelongsToOntologyModule(ArrayList<URI> val){
		boolean ret = true;
		
		this.belongsToOntologyModule = val;
		
		return ret;
	}

	public boolean addBelongsToOntologyModule( URI val) throws Exception {
		boolean ret = true;
		try {
			if( val != null ) {

				if( this.belongsToOntologyModule==null)
					this.belongsToOntologyModule = new ArrayList<URI>();
						
				this.belongsToOntologyModule.add( val );
			}
			
		} catch (Exception e) {
			logger.error( this.getClass().toString() + " addBelongsToOntologyModule(): " + e.getMessage() );
			ret = false;
			
			throw e;
		}
		return ret;
	}

	public boolean setHasPreviousVersion(URI val) {
		boolean ret = true;
		this.hasPreviousVersion = val;
		return ret;
	}
	
	// ##################################
	
	public URI getId(){
		return this.id;
	}
	
	public String getLabel(){
		return this.label;
	}
	
	public String getComment(){
		return this.comment;
	}
	
	public Date getHasVersionDateTime(){
		return this.hasVersionDateTime;
	}
	
	public ArrayList<URI> getSeeAlso(){
		return this.seeAlso;
	}
	
	public ArrayList<URI> getBelongsToOntologyModule() {
		return this.belongsToOntologyModule;
	}
	
	public ArrayList<TranslationContainer> getTranslations(){
		return this.translations;
	}
	
	public ArrayList<String> getSynonyms() {
		return this.synonyms;
	}
	
	public ArrayList<String> getTags() {
		return this.tags;
	}
	
	public ArrayList<String> getFlickrImages() {
		return this.flickrImages;
	}
	
	public ArrayList<String> getYouTubeVideos() {
		return this.youTubeVideos;
	}
	
	public String getExample(){
		return this.example;
	}

	public URI getHasPreviousVersion() {
		return hasPreviousVersion;
	}
	

	
	
}
